<template>
	<view class="member">
		<!-- #ifndef H5 -->
		<view class="head-nav bar-color"></view>
		<!-- #endif -->
		<!-- 个人信息 -->
		<view class="memberHeader">
			<view class="headerContent">
				<view v-if="memberData.member" class="left">
					<image :src="$util.img(memberData.member.avatar)"></image>
					<view class="heardCenter" @click="$util.redirectTo('/pages/settings/settings')">
						<view class="top">
							<text>{{memberData.member.nickname}}</text>
							<view class="topTitle">
								<text class="iconfont icon-huangguan"></text>{{memberData.member.levelname}}
							</view>
						</view>
						<view class="id">ID：{{memberData.member.id}}</view>
					</view>
				</view>
				<view class="right">
					<text class="iconHover iconfont icon-xinxi"
						@click="$util.redirectTo('/pages/messagecenter/messagecenter')"></text>
					<!-- <text class="iconHover iconfont icon-shezhi" @click="$util.redirectTo('/pages/settings/settings')"></text> -->
				</view>
			</view>
		</view>
		<!-- 钱包 -->
		<view class="moneybox" @click="$util.redirectTo('/pages/mywallet/mywallet')">
			<view class="moneybox-top">
				<text>我的钱包</text>
				<text class="iconfont icon-jinrujiantou"></text>
			</view>
			<view class="moneybox-bottom" v-if="memberData.member">
				<view class="moneybox-item">
					<text class="num">{{memberData.member.jrmoney || 0}}</text>
					<text class="title">今日收益</text>
				</view>
				<view class="moneybox-item">
					<text class="num">{{memberData.member.ljmoney || 0}}</text>
					<text class="title">累计收益</text>
				</view>
				<view class="moneybox-item">
					<text class="num">{{memberData.member.money || 0}}</text>
					<text class="title">余额</text>
				</view>
				<view class="moneybox-item">
					<text class="num">{{memberData.member.bondprice || 0}}</text>
					<text class="title">保证金</text>
					<view class="tips">发布专用</view>
				</view>
			</view>
			<view class="release" @click.stop="$util.redirectTo('/pages/release/release')">
				<text>发布/管理任务</text>
				<text class="iconfont icon-jinrujiantou"></text>
			</view>
		</view>
		<!-- 会员开通 -->
<!-- 		<view class="activation">
			<text>开通会员，获得更多惊喜权益</text>
			<view class="activation-button" @click="$util.redirectTo('/pages/member/member')">
				开通会员
			</view>
		</view> -->

		<!-- 接单管理 -->
		<view class="moneybox administration">
			<view class="moneybox-top">
				<text>接单管理</text>
				<text class="iconfont icon-jinrujiantou"
					@click="$util.redirectTo('/pages/ordermanagement/ordermanagement?status=0')"></text>
			</view>
			<view class="moneybox-bottom">
				<view class="moneybox-item" v-for="(item,index) in singleList" :key="index"
					@click="$util.redirectTo(item.link)">
					<image :src="item.src" mode=""></image>
					<text class="title">{{item.title}}</text>
				</view>
			</view>
		</view>
		<!-- 悬赏管理 -->
		<view class="moneybox administration">
			<view class="moneybox-top">
				<text>悬赏管理</text>
				<text class="iconfont icon-jinrujiantou"
					@click="$util.redirectTo('/pages/rewardmanagement/rewardmanagement?status=0')"></text>
			</view>
			<view class="moneybox-bottom">
				<view class="moneybox-item" v-for="(item,index) in tubeList" :key="index" v-show="item.value == '2'"
					@click="$util.redirectTo(item.link)">
					<image :src="item.src" mode=""></image>
					<text class="title">{{item.title}}</text>
				</view>
			</view>
		</view>
		<!-- 广告轮播 -->
		<view class="swiperContet" v-if="memberData.mysilde">
			<swiper class="swiper" circular="true" :indicator-dots="true" :autoplay="true" interval="2000">
				<swiper-item v-for="(item,index) in memberData.mysilde" :key="index"  @click="gotoUrl(item.link)">
					<image :src="$util.img(item.image)" mode="widthFix"></image>
				</swiper-item>
			</swiper>
		</view>
		<!-- 常用功能 -->
		<view class="moneybox administration" v-if="memberData.nav">
			<view class="moneybox-top">
				<text>常用功能</text>
			</view>
			<view class="moneybox-bottom common">
				<view class="moneybox-item" v-for="(item,index) in memberData.nav" :key="index"
					@click="item.link == 'diy' ? diy(item) : $util.redirectTo(item.link)">
					<image :src="$util.img(item.icon)" mode="widthFix"></image>
					<text class="title">{{item.name}}</text>
				</view>
			</view>
		</view>
		<!-- 加载 -->
		<loading-cover ref="loadingCover"></loading-cover>
		<!-- 底部导航 -->
		<diyTabBar value="personal"></diyTabBar>
	</view>
</template>

<script>
	import diyTabBar from '../../component/diy-nav/diy-tabbar.vue'
	import loadingCover from '../../component/loading-cover/loading-cover.vue'
	export default {
		components: {
			diyTabBar,
			loadingCover
		},
		data() {
			return {
				zpid: true, //判断是否为子账户
				// 钱包列表
				moneyList: [{
					num: '10.00',
					title: '今日收益'
				}, {
					num: '10.00',
					title: '累计收益'
				}, {
					num: '10.00',
					title: '余额'
				}, {
					num: '10.00',
					title: '保证金'
				}],
				//管理列表
				tubeList: [{
					title: '已上架',
					link: '/pages/rewardmanagement/rewardmanagement?status=0',
					src: '../../static/iconimg/07.png'
				}, {
					title: '待上架',
					link: '/pages/rewardmanagement/rewardmanagement?status=1',
					src: '../../static/iconimg/02.png'
				}, {
					title: '已暂停',
					link: '/pages/rewardmanagement/rewardmanagement?status=2',
					src: '../../static/iconimg/09.png'
				}, {
					title: '刷新',
					link: '/pages/refreshpurchase/refreshpurchase',
					src: '../../static/iconimg/06.png'
				},
				// {
				// 	title: '置顶包',
				// 	link: '/pages/topping/topping',
				// 	src: '../../static/iconimg/06.png'
				// },
				{
					title: '审核',
					link: '/pages/toexamine/toexamine?status=0',
					src: '../../static/iconimg/04.png'
				}],
				//接单管理
				singleList: [{
					title: '待提交',
					link: '/pages/ordermanagement/ordermanagement?status=1',
					src: '../../static/iconimg/03.png'
				}, {
					title: '审核中',
					link: '/pages/ordermanagement/ordermanagement?status=2',
					src: '../../static/iconimg/05.png'
				}, {
					title: '已完成',
					link: '/pages/ordermanagement/ordermanagement?status=4',
					src: '../../static/iconimg/08.png'
				}, {
					title: '不合格',
					link: '/pages/ordermanagement/ordermanagement?status=3',
					src: '../../static/iconimg/01.png'
				}, {
					title: '全部订单',
					link: '/pages/ordermanagement/ordermanagement?status=0',
					src: '../../static/iconimg/04.png'
				}],
				commonList: [{
					title: '我的团队',
					link: '/pages/myteam/myteam'
				}, {
					title: '邀请分享',
					link: '/pages/invitation/invitation',
					link: 'diy',
					type:'yq'
				}, {
					title: '举报维权',
					link: '/pages/report/report'
				}, {
					title: '子账号开通',
					link: '/pages/subaccountlist/subaccountlist'
				}, {
					title: '帮助中心',
					link: '/pages/helpcenter/helpcenter'
				}, {
					title: '消息中心',
					link: '/pages/messagecenter/messagecenter'
				}, {
					title: '关于我们'
				}, {
					title: '我的客服',
					link: '/pages/myservice/myservice'
				}, {
					title: '个人设置',
					link: '/pages/settings/settings'
				},{
					title: '下载',
					link: 'diy',
					type:'xz'
				}],
				// 个人中心数据
				memberData: [],
				//判断是否显示
				objShow: []
			}
		},
		onLoad(option) {
			this.zpid = uni.getStorageSync('zpid')

			//#ifdef APP
			uni.hideTabBar()
			//#endif
		},
		onShow() {
			this.$http.sendrequest('/index/Shelfmode').then(res => {
				this.tubeList.forEach((item, index) => {
					if (res.code == 1) {
						item.value = res.data[index + 2].value
					}
				})
				this.$forceUpdate();
			})
			this.getData();
		},
		methods: {
			gotoUrl(url) {
				// #ifdef H5
				window.location.href = url;
				// #endif
				// #ifdef APP
				plus.runtime.openURL(url);
				// #endif
			},
			getData() {
				this.$http.sendrequest('/member/memberInfo', {}, {
					tokenJudge: true
				}).then(res => {
					if (res.code == 1) {
						this.memberData = JSON.parse(JSON.stringify(res.data));
						uni.setStorageSync('member', this.memberData.member)
						this.memberData.nav.forEach(item => {
							switch (item.id) {
								case 141:
									item.link = '/pages/myteam/myteam'
									break;
								case 142:
									item.link = '/pages/invitation/invitation'
									// item.link = 'diy'
									// item.type = 'yq'
									break;
								case 143:
									item.link = '/pages/report/report'
									break;
								case 144:
									item.link = '/pages/subaccountlist/subaccountlist'
									break;
								case 146:
									item.link = '/pages/helpcenter/helpcenter'
									break;
								case 147:
									item.link = '/pages/messagecenter/messagecenter'
									break;
								case 148:
									item.link = '/pages/aboutus/aboutus'
									break;
								case 149:
									item.link = '/pages/myservice/myservice'
									break;
								case 156:
									item.link = '/pages/myshop/myshop?id=2'
									break;
								case 164:
									item.link = '/pages/settings/settings'
									break;
								case 163:
									item.link = '/pages/settings/settings'
									item.link = 'diy'
									item.type = 'xz'
									break;
							}
							this.$refs.loadingCover.hide();
						})
					}
					this.$forceUpdate();
				})
			},
			diy(item){
				let ua = uni.getSystemInfoSync().platform;
				switch(item.type){
					case 'xz':
						let status;
						if (/ios/i.test(ua)) {
							status = 2
						} else if (/android/i.test(ua)) {
							status = 1
						}
						this.$http.sendrequest('/index/xz',{status},{
							tokenJudge:true
						}).then(res=>{
							// #ifdef H5
							window.location.href = res.data;
							// #endif
							// #ifdef APP
							plus.runtime.openURL(res.data);
							// #endif
						})
						break;
					case 'yq':
						this.$util.redirectTo('/pages/Invitefriends/Invitefriends')
						break;
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import './css/personal.scss';

	.head-nav {
		width: 100%;
		height: var(--status-bar-height);
	}

	.bar-color {
		background: $uni-tabbar-hovercolor;
	}

	.release {
		width: 100%;
		padding: 20rpx 0 0;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 26rpx;
		margin-top: 40rpx;
		color: #FF6F30;
		font-weight: bold;
		border-top: 1rpx solid rgba(0, 0, 0, .1);
		text{
			font-size: 28rpx;
		}
		.icon-jinrujiantou {
			color: #898989;
			font-size: 38rpx;
			font-weight: bold;
		}
	}
</style>